<hr>
<p>title: 206.Reverse Linked List<br>date: 2021-10-13 16:31:14<br>tags:</p>
<pre><code>- LeeCode
</code></pre><p>categories:</p>
<pre><code>- LeeCode
</code></pre><p>hidden: true</p>
<h2 id="cateHidden-false"><a href="#cateHidden-false" class="headerlink" title="cateHidden: false"></a>cateHidden: false</h2><h3 id="描述"><a href="#描述" class="headerlink" title="描述"></a>描述</h3><blockquote>
<p>Given the head of a singly linked list, reverse the list, and return the reversed list.</p>
</blockquote>
<p>翻转链表。</p>
<h3 id="题解"><a href="#题解" class="headerlink" title="题解"></a>题解</h3><pre><code class="lang-js">var reverseList = function (head) {
  if (!head || !head.next) return head;
  let _head = head,
    _next = head.next;
  _head.next = null;
  while (_next) {
    let __next = _next.next; // 记录下一个节点
    // 反转当前节点
    _next.next = _head;
    _head = _next;
    _next = __next;
    if (!__next) {
      return _head;
    }
  }
};
</code></pre>
